package cn.wolfcode.p2p.base.controller;

import cn.wolfcode.p2p.base.anno.NeedLogin;
import cn.wolfcode.p2p.base.query.IpLogQueryObject;
import cn.wolfcode.p2p.base.service.IpLogService;
import cn.wolfcode.p2p.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 前台登录日志相关
 */
@Controller
public class IpLogController {

    @Autowired
    private IpLogService ipLogService;

    /**
     * 查询登录日志记录
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("ipLog")
    @NeedLogin
    public String iplog(@ModelAttribute("qo") IpLogQueryObject qo, Model model){

        qo.setOrderBy("login_time DESC");
        qo.setUsername(UserContext.getLoginInfo().getUsername());
        model.addAttribute("pageInfo",ipLogService.queryForPage(qo));
        return "iplog_list";
    }


}
